package com.pzb.web.controller.order;

import java.util.List;

import com.pzb.wechat.service.IWechatAppletService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.pzb.common.annotation.Log;
import com.pzb.common.core.controller.BaseController;
import com.pzb.common.core.domain.AjaxResult;
import com.pzb.common.enums.BusinessType;
import com.pzb.order.domain.OdOrderDetail;
import com.pzb.order.service.IOdOrderDetailService;
import com.pzb.common.core.page.TableDataInfo;

/**
 * 订单详情Controller
 * 
 * @author Mr_Wu
 * @date 2021-12-15
 */
@RestController
@RequestMapping("/order/orderDetail")
public class OdOrderDetailController extends BaseController
{
    @Autowired
    private IOdOrderDetailService odOrderDetailService;
    @Autowired
    private IWechatAppletService wechatAppletService;

    /**
     * 查询订单详情列表
     */
    @PreAuthorize("@ss.hasPermi('order:orderDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(OdOrderDetail odOrderDetail)
    {
        startPage();
        odOrderDetail.setExtAppid(wechatAppletService.getExtAppid());
        List<OdOrderDetail> list = odOrderDetailService.selectOdOrderDetailList(odOrderDetail);
        return getDataTable(list);
    }

    /**
     * 获取订单详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:orderDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(odOrderDetailService.selectOdOrderDetailById(id));
    }


    /**
     * 修改订单详情
     */
    @PreAuthorize("@ss.hasPermi('order:orderDetail:edit')")
    @Log(title = "订单详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OdOrderDetail odOrderDetail)
    {
        return toAjax(odOrderDetailService.updateOdOrderDetail(odOrderDetail));
    }

}
